﻿/*!
 * @file grayscalethresh.h
 * @author 川西康友
 * @date Last Change: 2011/Feb/24.
 * */

#ifndef __BGSSIMPLE__
#define __BGSSIMPLE__

#include "ImageBackgroundSubtractAlgorithm.h"

namespace mmpl{
	namespace image{
		/**
		 * @class BackgroundSubtractorGrayScaleThresh
		 * @brief 単純な背景差分アルゴリズムクラス
		 *
		 * StrategyパターンのConcreteStrategyに相当
		 * */
		class BackgroundSubtractorGrayScaleThresh:public BackgroundSubtractAlgorithm{
			public:
				BackgroundSubtractorGrayScaleThresh(const Image& bgimage,int threshold=0);
				BackgroundSubtractorGrayScaleThresh(const std::string& bgname,int threshold=0);
				BackgroundSubtractorGrayScaleThresh(int threshold=0);
				virtual ~BackgroundSubtractorGrayScaleThresh();

				virtual BackgroundSubtractorGrayScaleThresh* clone()const;
				virtual bool equals(const BackgroundSubtractAlgorithm& other)const;
				virtual void print(std::ostream& out)const;

				// その他のメソッド
				void setBGImage(const Image& bgimage);
				void setBGImage(const std::string& bgfilename);
				const Image& getBGImage()const;
				int getThreshold()const;
				void setThreshold(int thresh);
				virtual void apply(const Image& img,BGSubtractedImage* oimg);

			protected:
				BackgroundSubtractorGrayScaleThresh(const BackgroundSubtractorGrayScaleThresh& other);

			private:
				BackgroundSubtractorGrayScaleThresh& operator=(const BackgroundSubtractorGrayScaleThresh& other);

				Image bgimage;//!< 背景画像
				int threshold;
				bool isBGset;
		};
	}
}
#endif
